package com.own.component.store.core;

import com.own.component.store.core.method.StoreAtomic;
import com.own.component.store.core.method.StoreList;
import com.own.component.store.core.method.StoreMap;
import com.own.component.store.core.method.StoreSet;
import com.own.component.store.core.method.StoreValue;

/**
 * DefaultStore
 *
 * @author chenxueli
 * @date 2022-06-15 03:14:15
 */
public class DefaultStore<T> implements Store<T> {

    private final StoreValue<T> value;
    private final StoreMap<T> map;
    private final StoreSet<T> set;
    private final StoreList<T> list;
    private final StoreAtomic atomic;

    public DefaultStore(
            StoreValue<T> value,
            StoreMap<T> map,
            StoreSet<T> set,
            StoreList<T> list,
            StoreAtomic atomic
    ) {
        this.value = value;
        this.map = map;
        this.set = set;
        this.list = list;
        this.atomic = atomic;
    }

    /**
     * 获取K V操作对象
     *
     * @return value操作对象
     */
    @Override
    public StoreValue<T> value() {
        return value;
    }

    /**
     * 获取K Map操作对象
     *
     * @return hash操作对象
     */
    @Override
    public StoreMap<T> map() {
        return map;
    }

    /**
     * 获取K Set操作对象
     *
     * @return set操作兑现
     */
    @Override
    public StoreSet<T> set() {
        return set;
    }

    /**
     * 获取K List操作对象
     *
     * @return list操作对象
     */
    @Override
    public StoreList<T> list() {
        return list;
    }

    /**
     * 获取Atom操作对象
     *
     * @return atom操作对象
     */
    @Override
    public StoreAtomic atomic() {
        return atomic;
    }

    /**
     * 是否存在
     *
     * @param name name
     * @return 是否存在
     */
    @Override
    public boolean contains(String name) {
        return value.contains(name) || map.contains(name) || set.contains(name) || list.contains(name) || atomic.contains(name);
    }

}
